package com.example.contactcloud;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ChangeTheme extends Activity implements OnClickListener{

	static final String EXTRA_MESSAGE="";
	static final String EXTRA_MESSAGE2="";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setTheme(LoginActivity.globalTheme);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_change_theme);
		// Show the Up button in the action bar.

		findViewById(R.id.button1).setOnClickListener(this);
		findViewById(R.id.Button01).setOnClickListener(this);
		findViewById(R.id.Button02).setOnClickListener(this);

		
	//Navigates back to AllContacts
	Button cancelButton = (Button) findViewById(R.id.cancelButton);
	cancelButton.setOnClickListener(new View.OnClickListener() {
		public void onClick(View v){
			close();
		}
	});

	}
	@Override
	public void onClick(View v)
	{
		switch (v.getId())
		{
		case R.id.button1:
			LoginActivity.globalTheme = android.R.style.Theme_Holo;
			Utils.changeToTheme(this, Utils.THEME_DEFAULT);
			break;
		case R.id.Button01:
			LoginActivity.globalTheme = R.style.Theme_White;
			Utils.changeToTheme(this, Utils.THEME_WHITE);
			break;
		case R.id.Button02:
			LoginActivity.globalTheme = android.R.style.Theme_Holo_Light;
			Utils.changeToTheme(this, Utils.THEME_BLUE);
			break;
		}

	}

	private void close()
	{
		this.finish();
		Intent myIntent = new Intent(this, AllContacts.class); 
		myIntent.putExtra(EXTRA_MESSAGE, "false");
		startActivityForResult(myIntent, 0);
	}
	/**
	 * Set up the {@link android.app.ActionBar}, if the API is available.
	 */
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	private void setupActionBar() {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			getActionBar().setDisplayHomeAsUpEnabled(true);
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.change_theme, menu);
		return true;
	}
	

}
